import * as THREE from 'three'
export class MySprite {
    constructor ({ name, url, position, scale}) {
        const textureLoader = new THREE.TextureLoader()
        const texture = textureLoader.load(url)
        // SpriteMaterial-精灵材质
        const spriteMaterial = new THREE.SpriteMaterial({map: texture})
        // 创建精灵物体，设置位置和旋转
        const sprite = new THREE.Sprite(spriteMaterial)
        sprite.position.set(...position)
        sprite.scale.set(...scale)
        sprite.name = name
        // 直接返回sprite精灵物体对象，而非当前的this实例指向的对象
        // 如果class没有return，返回的就是当前class实例的对象
        return sprite
    }
}